from django.contrib import admin
from django.urls import path,include,re_path
from blog import  views
from django.views.static import serve   #导入静态文件模块
# from error.views import page_not_found,page_error
from blog import views
from article.feeds import AllArticlesRssFeed
from blog.sitemaps import ArticleSitemap,CategorySitemap,TagSitemap
#点地图生成功能
from django.contrib.sitemaps.views import sitemap
#静态目录文件设置
from django.conf import settings        #导入配置文件里的文件上传配置
from django.conf.urls.static import static

# 网站地图
sitemaps = {
    'articles': ArticleSitemap,
    'categories': CategorySitemap,
    'tags': TagSitemap
}

urlpatterns = [
    path('admin/', admin.site.urls),
    path('course/',include('course.urls')),
    path('',include('blog.urls')),
    path('',include('comments.urls')),
    # path('myaccount/', include('myaccount.urls')),
    # django-allauth用户自定义信息扩展
    re_path(r'^accounts/', include('myaccount.urls', namespace='accounts')),
    #django-allauth插件
    path('accounts/', include('allauth.urls')),
    path('',include('article.urls')),
    path('test/',include('testfunc.urls')),
    path('captcha/', include('captcha.urls')),
    # re_path(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},name='django.contrib.sitemaps.views.sitemap')
    # path('comments/', include('django_comments.urls')),
    re_path('^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),#增加此行
    path('get_valid_img/', views.get_valid_img,),
    # Rss订阅
    path('all/rss/', AllArticlesRssFeed(), name='rss'),
    # path('search/', include('haystack.urls')),
    path('mdeditor/', include('mdeditor.urls')),
    # 评论
    re_path(r'^comment/', include('comments.urls', namespace='Comment')),
    # 网站地图
    re_path(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),




]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)  # 加入这个才能显示media文件
